package com.example.zxx.springboot3.util;

import java.util.function.Consumer;

/**
 * ele
 */
public interface IThrowStringUtil extends IThrowObjectUtil {

    IThrowStringUtil BUILD = new IThrowStringUtil() {
    };

    default <RE extends RuntimeException> void throwofStrIsEmpty(RE re, String str) {
        throwOf((str == null || str.length() == 0), re);
    }

    default <RE extends RuntimeException> void throwofStrIsEmpty(Consumer<RE> before, RE re, String str) {
        throwOf(before, (str == null || str.length() == 0), re);
    }

    default void throwofStrIsEmpty(String errMessage, String str) {
        throwofStrIsEmpty(new RuntimeException(errMessage), str);
    }

    default void throwofStrIsEmpty(Consumer<RuntimeException> before, String errMessage, String str) {
        throwofStrIsEmpty(before, new RuntimeException(errMessage), str);
    }

    default <RE extends RuntimeException> void throwofStrNotEmpty(RE re, String str) {
        throwOf(!(str == null || str.length() == 0), re);
    }

    default <RE extends RuntimeException> void throwofStrNotEmpty(Consumer<RE> before, RE re, String str) {
        throwOf(before, !(str == null || str.length() == 0), re);
    }

    default void throwofStrNotEmpty(String errMessage, String str) {
        throwofStrNotEmpty(new RuntimeException(errMessage), str);
    }

    default void throwofStrNotEmpty(Consumer<RuntimeException> before, String errMessage, String str) {
        throwofStrNotEmpty(before, new RuntimeException(errMessage), str);
    }
}